package com.example.fastshareapp;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.widget.CalendarView;

public class Image {

	private int m_row;
	private List<Bitmap> m_imageColumn;
	private String m_imageName;
	public Image(int row,String imageName) {
		m_row = row;
		m_imageColumn = new ArrayList<Bitmap>();
		m_imageName = imageName;
	}
	public Image() {
		m_imageColumn = new ArrayList<Bitmap>();
	}
	
	public Image(int row)
	{
		m_row = row;
		m_imageColumn = new ArrayList<Bitmap>();
	}

	/**
	 * @return the m_row
	 */
	public synchronized int getM_row() {
		return m_row;
	}

	/**
	 * @param m_row
	 *            the m_row to set
	 */
	public synchronized void setM_row(int m_row) {
		this.m_row = m_row;
	}

	/**
	 * @return the m_imageColumn
	 */
	public synchronized List<Bitmap> getM_imageColumn() {
		return m_imageColumn;
	}

	/**
	 * @param m_imageColumn
	 *            the m_imageColumn to set
	 */
	public synchronized void setM_imageColumn(List<Bitmap> m_imageColumn) {
		this.m_imageColumn = m_imageColumn;
	}

	public void AddImage(Bitmap _image) {
		m_imageColumn.add(_image);
	}

	public Bitmap getImage(int index) {
		return m_imageColumn.get(index);
	}
	
	public int getHeight()
	{
		return m_imageColumn.get(0).getHeight();
	}
	
	public int getWidth()
	{
		int width = 0;
		for (Bitmap image: m_imageColumn)
		{
			width += image.getWidth();
		}
		return width;
	}
	
	public Bitmap makeImage()
	{
		int height = m_imageColumn.get(0).getHeight();
		int width = 0;
		for (Bitmap image: m_imageColumn)
		{
			width += image.getWidth();
		}
		
		Bitmap resutl = Bitmap.createBitmap(width,height,Config.ARGB_8888);
		Canvas combine = new Canvas(resutl);
		int posX = 0;
		int posY=0;
		for (Bitmap image: m_imageColumn)
		{
			combine.drawBitmap(image, posX, posY, null);
			posX+= image.getWidth();
		}
		return resutl;
	}
	/**
	 * @return the m_imageName
	 */
	public synchronized String getM_imageName() {
		return m_imageName;
	}
	/**
	 * @param m_imageName the m_imageName to set
	 */
	public synchronized void setM_imageName(String m_imageName) {
		this.m_imageName = m_imageName;
	}

}
